package com.neuedu.service.impl;

import com.neuedu.dao.UserCollectionDao;
import com.neuedu.model.UserCollection;
import com.neuedu.service.UserCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCollectionServiceImpl implements UserCollectionService {

    @Autowired
    private UserCollectionDao userCollectionDao;

    @Override
    public boolean addCollection(UserCollection userCollection) {
        int rows = userCollectionDao.insert(userCollection);
        return rows > 0;
    }

    @Override
    public List<UserCollection> queryCollectionsByUid(Integer uid) {
        return userCollectionDao.selectList(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<UserCollection>().eq("uid", uid));
    }

    @Override
    public boolean deleteCollection(Integer collectionId) {
        int rows = userCollectionDao.deleteById(collectionId);
        return rows > 0;
    }
}